package com.company.beauty.common.config.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * <p>okhttp相关配置信息</p>
 *
 * @author Lionel Lee
 * @version 1.0: OKHttpProperties.java
 * @date 2022/6/22 09:27
 */
@ConfigurationProperties(prefix = "okhttp.config")
@Component
@Data
@RefreshScope
public class OkHttpProperties {

    /**
     * Max Idle Connections
     */
    private Integer  maxIdleConnections        = 30;
    /**
     * 连接持续时间
     */
    private Long     keepAliveDuration         = 300L;
    /**
     * 复用时间单位
     */
    private TimeUnit keepAliveDurationTimeUnit = TimeUnit.MINUTES;
    /**
     * 连接超时时间
     */
    private Long     connectTimeout            = 10L;
    /**
     * 连接超时时间单位
     */
    private TimeUnit connectTimeoutTimeUnit    = TimeUnit.SECONDS;
    /**
     * 写超时时间
     */
    private Long     writeTimeout              = 10L;
    /**
     * 写超时时间单位
     */
    private TimeUnit writeTimeoutTimeUnit      = TimeUnit.SECONDS;
    /**
     * 读超时时间
     */
    private Long     readTimeout               = 10L;
    /**
     * 读超时时间单位
     */
    private TimeUnit readTimeoutTimeUnit       = TimeUnit.SECONDS;
    /**
     * 线程配置
     */
    private int      corePoolSize              = Runtime.getRuntime().availableProcessors();
    /**
     * 最大线程数
     */
    private int      maxPoolSize               = Runtime.getRuntime().availableProcessors() * 2;

}
